import { FormCard } from '@/model/types/formCard';
import { GetAllCard } from '@/global/util/common';

export const GetColumns = (formCards: FormCard[], formProperty: any) => {
  if (!formCards?.length) return [];
  // 去掉布局卡片
  const list = GetAllCard(formCards).filter((it) => it.group !== 'layout');
  const columns: any = list.map((card) => {
    const controls = card.controls ?? {};
    const { cardCode, displayName } = controls;
    return {
      title: displayName.defaultValue,
      dataIndex: cardCode.defaultValue,
      card,
    };
  });
  // 拼接数据标题
  columns.unshift({
    title: '数据标题',
    dataIndex: 'dataTitle',
    card: null,
  });
  return columns;
};
